Fortran For Fun 绘图函数库ogpf 发表于 2018-04-14 | 分类于 fortran ogpf (Object based interface to GnuPlot from Fortran )是利用fortran生成gnuplot脚本然后使用gnuplot进行绘图的一个函数库,使用较简单,可以绘制常用的曲线曲面图。 learn_ogpf123456789101112131415161718192021222324252627282930313233program learn_ogpf use ogpf implicit none call plot_surf()contains subroutine plot_surf() type(gpf):: gp real, parameter :: pi=4._wp*atan(1._wp) real, allocatable :: x(:,:), y(:,:), z(:,:) integer:: m, n call meshgrid(x, y, linspace(-2.0,2.0, 65), linspace(-2.0,3.0, 65) ) m=size(x,1) n=size(x,2) allocate( z(m,n) ) z = x * exp(-x**2 - y**2) call gp%options('unset key') call gp%options('unset surface') call gp%axis([real(wp):: -2, 2, -2, 3]) call gp%title('Surface example') call gp%options('unset border; unset tics') call gp%surf(x,y,z, palette='accent') end subroutine plot_surfend program learn_ogpf 结果 ogpf